package cn.schoolwow.workflow.module.task.action.flow.complete.nodeType.gateway.common;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.workflow.domain.deploy.DeployGatewayPositionType;
import cn.schoolwow.workflow.domain.deploy.DeployNodeType;
import cn.schoolwow.workflow.entity.WorkFlowNode;

public class SetCurrentGatewayNodeCommonFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        WorkFlowNode nextNode = flowContext.checkData("nextNode", WorkFlowNode.class);
        flowContext.putCurrentFlowData("gatewayNode", nextNode);

        DeployGatewayPositionType deployGatewayPositionType = DeployGatewayPositionType.getDeployGatewayPositionType(nextNode.getGatewayPosition());
        flowContext.putCurrentFlowInstanceData(deployGatewayPositionType);

        String gatewayNodeTypeName = null;
        DeployNodeType deployNodeType = DeployNodeType.getDeployNodeType(nextNode.getType());
        switch (deployNodeType){
            case InclusiveGateway:{gatewayNodeTypeName = "包容网关";}break;
            case ExclusiveGateway:{gatewayNodeTypeName = "排他网关";}break;
            case ParallelGateway:{gatewayNodeTypeName = "并行网关";}break;
        }
        flowContext.putCurrentFlowData("gatewayNodeTypeName", gatewayNodeTypeName);
    }

    @Override
    public String name() {
        return "设置当前网关信息公共流程";
    }
}
